package com.xbongbong.saas.domain.dao;

import java.util.List;
import java.util.Map;

import com.xbongbong.saas.domain.entity.DistributorAccountEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface DistributorAccountDao {
    Long insert(DistributorAccountEntity entity);

    void insertBatch(List<DistributorAccountEntity> list);

    DistributorAccountEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    Integer update(DistributorAccountEntity entity);

    List<DistributorAccountEntity> findEntities(@Param("param") Map<String, Object> param);

    Integer getEntitiesCount(@Param("param") Map<String, Object> param);

    void updateBatch(@Param("list") List<DistributorAccountEntity> list);

    String getPhoneByOpenId(@Param("openId") String openId);

    Integer getMaxSort(@Param("corpid") String corpid, @Param("distributorId") Long distributorId);

    List<DistributorAccountEntity> getByIdIn(@Param("corpid") String corpid, @Param("list") List<Long> idIn);

    List<DistributorAccountEntity> getByDistributorIdIn(@Param("corpid") String corpid, @Param("list") List<Long> distributorIdIn);

    /**
     * 启用中的号码是否有重复
     *
     * @param corpid
     * @param phone
     * @param dataId
     * @return
     */
    List<DistributorAccountEntity> phoneRepeat(@Param("corpid") String corpid, @Param("phone") String phone, @Param("id") Long dataId);

    List<DistributorAccountEntity> getAllDistributorUserList(@Param("corpid") String corpid, @Param("distributorId") long distributorId, @Param("role") String role);

    List<DistributorAccountEntity> getDistributorAccountNum(@Param("corpid") String corpid);

    Integer isExists(@Param("corpid") String corpid, @Param("phone") String phone);
}
